package net.kleinhenz.norabase.server;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;

public class CSVReader {

	public static List<String> readFile(File file) throws java.io.IOException {
		BufferedReader r = new BufferedReader(new FileReader(file));
		List<String> lines = new ArrayList<String>();
		String line = null;
		while ((line=r.readLine())!=null)
			lines.add(line);
		r.close();
		return lines;
	}
	
	public static Map<String, Integer> getSonyMap() throws IOException {

		Map<String, Integer> sM = new HashMap<String, Integer>();
		for (String l : readFile(new File("WEB-INF/runeimg.csv"))) {
			StringTokenizer t = new StringTokenizer(l, ";");
			String type = t.nextToken();
			String xmlId = t.nextToken();
			Integer sonyId = new Integer(t.nextToken());
			sM.put(type + xmlId, sonyId);
		}
		return sM;		
	}

}
